package cn.spike.rockcc.fallback;

import cn.spike.rockcc.errorenum.GlobalExceptionCode;
import cn.spike.rockcc.exception.BusinessException;
import cn.spike.rockcc.feignclient.UserFeignClient;
import cn.spike.rockcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author:spike
 * @create:2023-03-09 00:17
 */
@Component
public class UserFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public JSONResult loadByPhone(String phone) {
                return JSONResult.error(GlobalExceptionCode.USERFEIGNCLIENT_EXCEPTION);
            }
        };
    }
}
